<template>
	<slot
		:controller="controller"
		:store="store"
		:model="model"
		:singleSelect="singleSelect"
		:actions="{ handleCtrlInit, handleCtrlAction }"
	>
		<div :class="classNames" style="">
			<component
				openType="EMBED"
				class="view-container2"
				:is="model.embedViewCodeName"
				:name="model.embedViewCodeName"
				:context="store.context"
				:noViewCaption="true"
				:viewParams="store.viewParams"
				:singleSelect="singleSelect"
				@view-init="(name: string, data: any) => handleCtrlInit(controller, name, data)"
				@view-action="(name: string, action: string, data: IParam[]) => handleCtrlAction(controller, name, action, data)"
			>
			</component>
		</div>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@PICKUPVIEWPANEL}}-pickup-view-panel/{{spinalCase ctrl.codeName}}-pickup-view-panel-base.vue.hbs生成
import {
	useProps,
	useBasic,
	useAction,
	useController,
} from './parent-org-pickup-viewpickupviewpanel-pickup-view-panel-hook';
import {
	PickupViewPanelActionType,
	IPickupViewPanelAbility,
	IPickupViewPanelStore,
	IParam,
	IViewLogicInput,
} from '@/core/interface';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const {
	model,
	controlID,
	getClassNames,
	useNavParamsBind,
	useEventBind,
	handleCtrlAction,
	handleCtrlInit,
} = useBasic(props);

const emit = defineEmits<{
	(
		event: 'ctrl-action',
		name: string,
		action: PickupViewPanelActionType,
		data: IParam[]
	): void;
	(event: 'ctrl-init', name: string, data: IPickupViewPanelAbility): void;
	(event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
	return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: IPickupViewPanelStore = controller.getStore();

onMounted(() => {
	controller.ctrlMounted();
});

onUnmounted(() => {
	controller.ctrlDestroy();
});
</script>
